/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
import org.netbeans.microedition.lcdui.LoginScreen;
import org.netbeans.microedition.lcdui.SplashScreen;
import org.netbeans.microedition.lcdui.WaitScreen;
import org.netbeans.microedition.util.SimpleCancellableTask;

/**
 * @author Familia
 */
public class LectMedicion extends MIDlet implements CommandListener {

    private boolean midletPaused = false;
    private String nombre="";
    private String pass="";
    private Comunicacion com;
    private MiWaitScreen wait_screen;
    private String usuario;
    private String nombre_usuario;
    //<editor-fold defaultstate="collapsed" desc=" Generated Fields ">//GEN-BEGIN:|fields|0|
    private LoginScreen loginScreen;
    private SplashScreen splashScreen;
    private Form form;
    private Alert alert;
    private List lista_menu;
    private Form formRegistro;
    private TextField textField1;
    private TextField textField2;
    private TextField textField;
    private Form formConsultaCliente;
    private TextField textField3;
    private StringItem stringItem;
    private Command okCommand;
    private Command exitCommand;
    private Command exitCommand1;
    private Command okCommand2;
    private Command okCommand1;
    private Command backCommand;
    private Command backCommand1;
    private Command okCommand3;
    private Ticker ticker1;
    private Font font1;
    private Image image1;
    private SimpleCancellableTask task;
    //</editor-fold>//GEN-END:|fields|0|

    /**
     * The VisualMIDlet constructor.
     */
    public LectMedicion() {
        com=new Comunicacion(this);
    }

    //<editor-fold defaultstate="collapsed" desc=" Generated Methods ">//GEN-BEGIN:|methods|0|
    //</editor-fold>//GEN-END:|methods|0|

    //<editor-fold defaultstate="collapsed" desc=" Generated Method: initialize ">//GEN-BEGIN:|0-initialize|0|0-preInitialize
    /**
     * Initilizes the application.
     * It is called only once when the MIDlet is started. The method is called before the <code>startMIDlet</code> method.
     */
    private void initialize() {//GEN-END:|0-initialize|0|0-preInitialize
        // write pre-initialize user code here
//GEN-LINE:|0-initialize|1|0-postInitialize

    }//GEN-BEGIN:|0-initialize|2|
    //</editor-fold>//GEN-END:|0-initialize|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Method: startMIDlet ">//GEN-BEGIN:|3-startMIDlet|0|3-preAction
    /**
     * Performs an action assigned to the Mobile Device - MIDlet Started point.
     */
    public void startMIDlet() {//GEN-END:|3-startMIDlet|0|3-preAction
        // write pre-action user code here
        switchDisplayable(null, getSplashScreen());//GEN-LINE:|3-startMIDlet|1|3-postAction

    }//GEN-BEGIN:|3-startMIDlet|2|
    //</editor-fold>//GEN-END:|3-startMIDlet|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Method: resumeMIDlet ">//GEN-BEGIN:|4-resumeMIDlet|0|4-preAction
    /**
     * Performs an action assigned to the Mobile Device - MIDlet Resumed point.
     */
    public void resumeMIDlet() {//GEN-END:|4-resumeMIDlet|0|4-preAction
        // write pre-action user code here
//GEN-LINE:|4-resumeMIDlet|1|4-postAction
        // write post-action user code here
    }//GEN-BEGIN:|4-resumeMIDlet|2|
    //</editor-fold>//GEN-END:|4-resumeMIDlet|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Method: switchDisplayable ">//GEN-BEGIN:|5-switchDisplayable|0|5-preSwitch
    /**
     * Switches a current displayable in a display. The <code>display</code> instance is taken from <code>getDisplay</code> method. This method is used by all actions in the design for switching displayable.
     * @param alert the Alert which is temporarily set to the display; if <code>null</code>, then <code>nextDisplayable</code> is set immediately
     * @param nextDisplayable the Displayable to be set
     */
    public void switchDisplayable(Alert alert, Displayable nextDisplayable) {//GEN-END:|5-switchDisplayable|0|5-preSwitch
        // write pre-switch user code here
        Display display = getDisplay();//GEN-BEGIN:|5-switchDisplayable|1|5-postSwitch
        if (alert == null) {
            display.setCurrent(nextDisplayable);
        } else {
            display.setCurrent(alert, nextDisplayable);
        }//GEN-END:|5-switchDisplayable|1|5-postSwitch
        // write post-switch user code here
    }//GEN-BEGIN:|5-switchDisplayable|2|
    //</editor-fold>//GEN-END:|5-switchDisplayable|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Method: commandAction for Displayables ">//GEN-BEGIN:|7-commandAction|0|7-preCommandAction
    /**
     * Called by a system to indicated that a command has been invoked on a particular displayable.
     * @param command the Command that was invoked
     * @param displayable the Displayable where the command was invoked
     */
    public void commandAction(Command command, Displayable displayable) {//GEN-END:|7-commandAction|0|7-preCommandAction
        // write pre-action user code here
        if (displayable == form) {//GEN-BEGIN:|7-commandAction|1|49-preAction
            if (command == exitCommand) {//GEN-END:|7-commandAction|1|49-preAction
                // write pre-action user code here
                exitMIDlet();//GEN-LINE:|7-commandAction|2|49-postAction
                // write post-action user code here
            }//GEN-BEGIN:|7-commandAction|3|118-preAction
        } else if (displayable == formConsultaCliente) {
            if (command == backCommand1) {//GEN-END:|7-commandAction|3|118-preAction
                // write pre-action user code here
                switchDisplayable(null, getLista_menu());//GEN-LINE:|7-commandAction|4|118-postAction
                // write post-action user code here
            } else if (command == okCommand3) {//GEN-LINE:|7-commandAction|5|115-preAction
                // write pre-action user code here
//GEN-LINE:|7-commandAction|6|115-postAction

                com.getDatosCliente(textField3.getString().trim());
            }//GEN-BEGIN:|7-commandAction|7|107-preAction
        } else if (displayable == formRegistro) {
            if (command == backCommand) {//GEN-END:|7-commandAction|7|107-preAction
                // write pre-action user code here
                switchDisplayable(null, getLista_menu());//GEN-LINE:|7-commandAction|8|107-postAction
                // write post-action user code here
            } else if (command == okCommand2) {//GEN-LINE:|7-commandAction|9|103-preAction
                // write pre-action user code here
//GEN-LINE:|7-commandAction|10|103-postAction
                // write post-action user code here
            }//GEN-BEGIN:|7-commandAction|11|79-preAction
        } else if (displayable == lista_menu) {
            if (command == List.SELECT_COMMAND) {//GEN-END:|7-commandAction|11|79-preAction
                // write pre-action user code here
                lista_menuAction();//GEN-LINE:|7-commandAction|12|79-postAction
                // write post-action user code here
            }//GEN-BEGIN:|7-commandAction|13|15-preAction
        } else if (displayable == loginScreen) {
            if (command == LoginScreen.LOGIN_COMMAND) {//GEN-END:|7-commandAction|13|15-preAction
                nombre=loginScreen.getUsername();
                pass=loginScreen.getPassword();
//GEN-LINE:|7-commandAction|14|15-postAction
               // com.conectar();
                wait_screen=new MiWaitScreen();
                switchDisplayable(null,wait_screen );
                com.loguear();
                //splashScreen.setText("Usuario: "+nombre+" Pass: "+pass);
            } else if (command == exitCommand1) {//GEN-LINE:|7-commandAction|15|64-preAction
                // write pre-action user code here
                exitMIDlet();//GEN-LINE:|7-commandAction|16|64-postAction
                // write post-action user code here
            }//GEN-BEGIN:|7-commandAction|17|24-preAction
        } else if (displayable == splashScreen) {
            if (command == SplashScreen.DISMISS_COMMAND) {//GEN-END:|7-commandAction|17|24-preAction
                // write pre-action user code here
                switchDisplayable(null, getLoginScreen());//GEN-LINE:|7-commandAction|18|24-postAction
                // write post-action user code here
            }//GEN-BEGIN:|7-commandAction|19|7-postCommandAction
        }//GEN-END:|7-commandAction|19|7-postCommandAction
        // write post-action user code here
    }//GEN-BEGIN:|7-commandAction|20|123-postAction
    //</editor-fold>//GEN-END:|7-commandAction|20|123-postAction


    public void setRespuesta(String resp){
        form.append(resp);
    }
    public String getName(){
        return nombre;
    }
    public String getPass(){
        return pass;
    }

    public String getUsuario() {
        return usuario;
    }

    public void setUsuario(String usuario) {
        this.usuario = usuario;
    }

    public String getNombre_usuario() {
        return nombre_usuario;
    }

    public void setNombre_usuario(String nombre_usuario) {
        this.nombre_usuario = nombre_usuario;
    }

    public void verCliente(String nombre){
        this.stringItem.setText(nombre);
    }

    
    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: loginScreen ">//GEN-BEGIN:|13-getter|0|13-preInit
    /**
     * Returns an initiliazed instance of loginScreen component.
     * @return the initialized component instance
     */
    public LoginScreen getLoginScreen() {
        if (loginScreen == null) {//GEN-END:|13-getter|0|13-preInit
            // write pre-init user code here
            loginScreen = new LoginScreen(getDisplay());//GEN-BEGIN:|13-getter|1|13-postInit
            loginScreen.setLabelTexts("Usuario", "Clave");
            loginScreen.setTitle("EPS GRAU SA");
            loginScreen.setTicker(getTicker1());
            loginScreen.addCommand(LoginScreen.LOGIN_COMMAND);
            loginScreen.addCommand(getExitCommand1());
            loginScreen.setCommandListener(this);
            loginScreen.setBGColor(-16750900);
            loginScreen.setFGColor(-1);
            loginScreen.setLoginTitle("Bienvenido");
            loginScreen.setUseLoginButton(false);
            loginScreen.setLoginButtonText("Acceder");//GEN-END:|13-getter|1|13-postInit
            // write post-init user code here
        }//GEN-BEGIN:|13-getter|2|
        return loginScreen;
    }
    //</editor-fold>//GEN-END:|13-getter|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: okCommand ">//GEN-BEGIN:|19-getter|0|19-preInit
    /**
     * Returns an initiliazed instance of okCommand component.
     * @return the initialized component instance
     */
    public Command getOkCommand() {
        if (okCommand == null) {//GEN-END:|19-getter|0|19-preInit
            // write pre-init user code here
            okCommand = new Command("Ok", Command.OK, 0);//GEN-LINE:|19-getter|1|19-postInit
            // write post-init user code here
        }//GEN-BEGIN:|19-getter|2|
        return okCommand;
    }
    //</editor-fold>//GEN-END:|19-getter|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: splashScreen ">//GEN-BEGIN:|22-getter|0|22-preInit
    /**
     * Returns an initiliazed instance of splashScreen component.
     * @return the initialized component instance
     */
    public SplashScreen getSplashScreen() {
        if (splashScreen == null) {//GEN-END:|22-getter|0|22-preInit
            // write pre-init user code here
            splashScreen = new SplashScreen(getDisplay());//GEN-BEGIN:|22-getter|1|22-postInit
            splashScreen.setTitle("EPS GRAU SA");
            splashScreen.setCommandListener(this);
            splashScreen.setFullScreenMode(true);
            splashScreen.setImage(getImage1());
            splashScreen.setText("Modulo de Ingreso de Lecturas");
            splashScreen.setTextFont(getFont1());
            splashScreen.setTimeout(4000);//GEN-END:|22-getter|1|22-postInit

        }//GEN-BEGIN:|22-getter|2|
        return splashScreen;
    }
    //</editor-fold>//GEN-END:|22-getter|2|





    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: form ">//GEN-BEGIN:|45-getter|0|45-preInit
    /**
     * Returns an initiliazed instance of form component.
     * @return the initialized component instance
     */
    public Form getForm() {
        if (form == null) {//GEN-END:|45-getter|0|45-preInit
            // write pre-init user code here
            form = new Form("datos obtenidos");//GEN-BEGIN:|45-getter|1|45-postInit
            form.addCommand(getExitCommand());
            form.setCommandListener(this);//GEN-END:|45-getter|1|45-postInit
            // write post-init user code here
        }//GEN-BEGIN:|45-getter|2|
        return form;
    }
    //</editor-fold>//GEN-END:|45-getter|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: exitCommand ">//GEN-BEGIN:|48-getter|0|48-preInit
    /**
     * Returns an initiliazed instance of exitCommand component.
     * @return the initialized component instance
     */
    public Command getExitCommand() {
        if (exitCommand == null) {//GEN-END:|48-getter|0|48-preInit
            // write pre-init user code here
            exitCommand = new Command("Exit", Command.EXIT, 0);//GEN-LINE:|48-getter|1|48-postInit
            // write post-init user code here
        }//GEN-BEGIN:|48-getter|2|
        return exitCommand;
    }
    //</editor-fold>//GEN-END:|48-getter|2|





    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: alert ">//GEN-BEGIN:|59-getter|0|59-preInit
    /**
     * Returns an initiliazed instance of alert component.
     * @return the initialized component instance
     */
    public Alert getAlert() {
        if (alert == null) {//GEN-END:|59-getter|0|59-preInit
            // write pre-init user code here
            alert = new Alert("alert", "no se puedo", null, null);//GEN-BEGIN:|59-getter|1|59-postInit
            alert.setTimeout(Alert.FOREVER);//GEN-END:|59-getter|1|59-postInit
            // write post-init user code here
        }//GEN-BEGIN:|59-getter|2|
        return alert;
    }
    //</editor-fold>//GEN-END:|59-getter|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: exitCommand1 ">//GEN-BEGIN:|63-getter|0|63-preInit
    /**
     * Returns an initiliazed instance of exitCommand1 component.
     * @return the initialized component instance
     */
    public Command getExitCommand1() {
        if (exitCommand1 == null) {//GEN-END:|63-getter|0|63-preInit
            // write pre-init user code here
            exitCommand1 = new Command("Salir", "Salir del Sistema", Command.EXIT, 0);//GEN-LINE:|63-getter|1|63-postInit
            // write post-init user code here
        }//GEN-BEGIN:|63-getter|2|
        return exitCommand1;
    }
    //</editor-fold>//GEN-END:|63-getter|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: font1 ">//GEN-BEGIN:|73-getter|0|73-preInit
    /**
     * Returns an initiliazed instance of font1 component.
     * @return the initialized component instance
     */
    public Font getFont1() {
        if (font1 == null) {//GEN-END:|73-getter|0|73-preInit
            // write pre-init user code here
            font1 = Font.getFont(Font.FACE_PROPORTIONAL, Font.STYLE_BOLD, Font.SIZE_SMALL);//GEN-LINE:|73-getter|1|73-postInit
            // write post-init user code here
        }//GEN-BEGIN:|73-getter|2|
        return font1;
    }
    //</editor-fold>//GEN-END:|73-getter|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: image1 ">//GEN-BEGIN:|74-getter|0|74-preInit
    /**
     * Returns an initiliazed instance of image1 component.
     * @return the initialized component instance
     */
    public Image getImage1() {
        if (image1 == null) {//GEN-END:|74-getter|0|74-preInit
            // write pre-init user code here
            try {//GEN-BEGIN:|74-getter|1|74-@java.io.IOException
                image1 = Image.createImage("/img/logo.png");
            } catch (java.io.IOException e) {//GEN-END:|74-getter|1|74-@java.io.IOException
                e.printStackTrace();
            }//GEN-LINE:|74-getter|2|74-postInit
            // write post-init user code here
        }//GEN-BEGIN:|74-getter|3|
        return image1;
    }
    //</editor-fold>//GEN-END:|74-getter|3|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: ticker1 ">//GEN-BEGIN:|76-getter|0|76-preInit
    /**
     * Returns an initiliazed instance of ticker1 component.
     * @return the initialized component instance
     */
    public Ticker getTicker1() {
        if (ticker1 == null) {//GEN-END:|76-getter|0|76-preInit
            // write pre-init user code here
            ticker1 = new Ticker("Modulo de Ingreso de Lecturas");//GEN-LINE:|76-getter|1|76-postInit
            // write post-init user code here
        }//GEN-BEGIN:|76-getter|2|
        return ticker1;
    }
    //</editor-fold>//GEN-END:|76-getter|2|
    //</editor-fold>

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: lista_menu ">//GEN-BEGIN:|77-getter|0|77-preInit
    /**
     * Returns an initiliazed instance of lista_menu component.
     * @return the initialized component instance
     */
    public List getLista_menu() {
        if (lista_menu == null) {//GEN-END:|77-getter|0|77-preInit
            // write pre-init user code here
            lista_menu = new List("Menu de Opciones", Choice.IMPLICIT);//GEN-BEGIN:|77-getter|1|77-postInit
            lista_menu.append("Ingreso de Lectura", null);
            lista_menu.append("Actualizacion de Lectura", null);
            lista_menu.append("Consultar Cliente", null);
            lista_menu.append("Ayuda", null);
            lista_menu.append("Salir", null);
            lista_menu.setCommandListener(this);
            lista_menu.setFitPolicy(Choice.TEXT_WRAP_ON);
            lista_menu.setSelectedFlags(new boolean[] { false, false, false, false, false });//GEN-END:|77-getter|1|77-postInit
            // write post-init user code here
        }//GEN-BEGIN:|77-getter|2|
        return lista_menu;
    }
    //</editor-fold>//GEN-END:|77-getter|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Method: lista_menuAction ">//GEN-BEGIN:|77-action|0|77-preAction
    /**
     * Performs an action assigned to the selected list element in the lista_menu component.
     */
    public void lista_menuAction() {//GEN-END:|77-action|0|77-preAction
        // enter pre-action user code here
        String __selectedString = getLista_menu().getString(getLista_menu().getSelectedIndex());//GEN-BEGIN:|77-action|1|81-preAction
        if (__selectedString != null) {
            if (__selectedString.equals("Ingreso de Lectura")) {//GEN-END:|77-action|1|81-preAction
                // write pre-action user code here
                switchDisplayable(null, getFormRegistro());//GEN-LINE:|77-action|2|81-postAction
                // write post-action user code here
            } else if (__selectedString.equals("Actualizacion de Lectura")) {//GEN-LINE:|77-action|3|82-preAction
                // write pre-action user code here
//GEN-LINE:|77-action|4|82-postAction
                // write post-action user code here
            } else if (__selectedString.equals("Consultar Cliente")) {//GEN-LINE:|77-action|5|85-preAction
                // write pre-action user code here
                switchDisplayable(null, getFormConsultaCliente());//GEN-LINE:|77-action|6|85-postAction
                // write post-action user code here
            } else if (__selectedString.equals("Ayuda")) {//GEN-LINE:|77-action|7|83-preAction
                // write pre-action user code here
//GEN-LINE:|77-action|8|83-postAction
                // write post-action user code here
            } else if (__selectedString.equals("Salir")) {//GEN-LINE:|77-action|9|84-preAction
                exitMIDlet();
//GEN-LINE:|77-action|10|84-postAction
                // write post-action user code here
            }//GEN-BEGIN:|77-action|11|77-postAction
        }//GEN-END:|77-action|11|77-postAction
        // enter post-action user code here
    }//GEN-BEGIN:|77-action|12|
    //</editor-fold>//GEN-END:|77-action|12|
    //</editor-fold>

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: formRegistro ">//GEN-BEGIN:|92-getter|0|92-preInit
    /**
     * Returns an initiliazed instance of formRegistro component.
     * @return the initialized component instance
     */
    public Form getFormRegistro() {
        if (formRegistro == null) {//GEN-END:|92-getter|0|92-preInit
            // write pre-init user code here
            formRegistro = new Form("form1", new Item[] { getTextField(), getTextField1(), getTextField2() });//GEN-BEGIN:|92-getter|1|92-postInit
            formRegistro.addCommand(getOkCommand2());
            formRegistro.addCommand(getBackCommand());
            formRegistro.setCommandListener(this);//GEN-END:|92-getter|1|92-postInit
            // write post-init user code here
        }//GEN-BEGIN:|92-getter|2|
        return formRegistro;
    }
    //</editor-fold>//GEN-END:|92-getter|2|





    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: okCommand1 ">//GEN-BEGIN:|96-getter|0|96-preInit
    /**
     * Returns an initiliazed instance of okCommand1 component.
     * @return the initialized component instance
     */
    public Command getOkCommand1() {
        if (okCommand1 == null) {//GEN-END:|96-getter|0|96-preInit
            // write pre-init user code here
            okCommand1 = new Command("Ok", Command.OK, 0);//GEN-LINE:|96-getter|1|96-postInit
            // write post-init user code here
        }//GEN-BEGIN:|96-getter|2|
        return okCommand1;
    }
    //</editor-fold>//GEN-END:|96-getter|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: textField ">//GEN-BEGIN:|99-getter|0|99-preInit
    /**
     * Returns an initiliazed instance of textField component.
     * @return the initialized component instance
     */
    public TextField getTextField() {
        if (textField == null) {//GEN-END:|99-getter|0|99-preInit
            // write pre-init user code here
            textField = new TextField("Ingrese codigo", null, 32, TextField.ANY);//GEN-LINE:|99-getter|1|99-postInit
            // write post-init user code here
        }//GEN-BEGIN:|99-getter|2|
        return textField;
    }
    //</editor-fold>//GEN-END:|99-getter|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: textField1 ">//GEN-BEGIN:|100-getter|0|100-preInit
    /**
     * Returns an initiliazed instance of textField1 component.
     * @return the initialized component instance
     */
    public TextField getTextField1() {
        if (textField1 == null) {//GEN-END:|100-getter|0|100-preInit
            // write pre-init user code here
            textField1 = new TextField("Ingrese medida", null, 32, TextField.ANY);//GEN-LINE:|100-getter|1|100-postInit
            // write post-init user code here
        }//GEN-BEGIN:|100-getter|2|
        return textField1;
    }
    //</editor-fold>//GEN-END:|100-getter|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: textField2 ">//GEN-BEGIN:|101-getter|0|101-preInit
    /**
     * Returns an initiliazed instance of textField2 component.
     * @return the initialized component instance
     */
    public TextField getTextField2() {
        if (textField2 == null) {//GEN-END:|101-getter|0|101-preInit
            // write pre-init user code here
            textField2 = new TextField("Ingrese Observacion", null, 32, TextField.ANY);//GEN-LINE:|101-getter|1|101-postInit
            // write post-init user code here
        }//GEN-BEGIN:|101-getter|2|
        return textField2;
    }
    //</editor-fold>//GEN-END:|101-getter|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: okCommand2 ">//GEN-BEGIN:|102-getter|0|102-preInit
    /**
     * Returns an initiliazed instance of okCommand2 component.
     * @return the initialized component instance
     */
    public Command getOkCommand2() {
        if (okCommand2 == null) {//GEN-END:|102-getter|0|102-preInit
            // write pre-init user code here
            okCommand2 = new Command("Enviar", Command.OK, 0);//GEN-LINE:|102-getter|1|102-postInit
            // write post-init user code here
        }//GEN-BEGIN:|102-getter|2|
        return okCommand2;
    }
    //</editor-fold>//GEN-END:|102-getter|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: backCommand ">//GEN-BEGIN:|106-getter|0|106-preInit
    /**
     * Returns an initiliazed instance of backCommand component.
     * @return the initialized component instance
     */
    public Command getBackCommand() {
        if (backCommand == null) {//GEN-END:|106-getter|0|106-preInit
            // write pre-init user code here
            backCommand = new Command("Atras", Command.BACK, 0);//GEN-LINE:|106-getter|1|106-postInit
            // write post-init user code here
        }//GEN-BEGIN:|106-getter|2|
        return backCommand;
    }
    //</editor-fold>//GEN-END:|106-getter|2|
    //</editor-fold>

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: formConsultaCliente ">//GEN-BEGIN:|109-getter|0|109-preInit
    /**
     * Returns an initiliazed instance of formConsultaCliente component.
     * @return the initialized component instance
     */
    public Form getFormConsultaCliente() {
        if (formConsultaCliente == null) {//GEN-END:|109-getter|0|109-preInit
            // write pre-init user code here
            formConsultaCliente = new Form("Consulta de Cliente", new Item[] { getTextField3(), getStringItem() });//GEN-BEGIN:|109-getter|1|109-postInit
            formConsultaCliente.addCommand(getOkCommand3());
            formConsultaCliente.addCommand(getBackCommand1());
            formConsultaCliente.setCommandListener(this);//GEN-END:|109-getter|1|109-postInit
            // write post-init user code here
        }//GEN-BEGIN:|109-getter|2|
        return formConsultaCliente;
    }
    //</editor-fold>//GEN-END:|109-getter|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: textField3 ">//GEN-BEGIN:|111-getter|0|111-preInit
    /**
     * Returns an initiliazed instance of textField3 component.
     * @return the initialized component instance
     */
    public TextField getTextField3() {
        if (textField3 == null) {//GEN-END:|111-getter|0|111-preInit
            // write pre-init user code here
            textField3 = new TextField("Ingrese Codigo", null, 32, TextField.ANY);//GEN-LINE:|111-getter|1|111-postInit
            // write post-init user code here
        }//GEN-BEGIN:|111-getter|2|
        return textField3;
    }
    //</editor-fold>//GEN-END:|111-getter|2|



    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: okCommand3 ">//GEN-BEGIN:|114-getter|0|114-preInit
    /**
     * Returns an initiliazed instance of okCommand3 component.
     * @return the initialized component instance
     */
    public Command getOkCommand3() {
        if (okCommand3 == null) {//GEN-END:|114-getter|0|114-preInit
            // write pre-init user code here
            okCommand3 = new Command("Ok", Command.OK, 0);//GEN-LINE:|114-getter|1|114-postInit
            // write post-init user code here
        }//GEN-BEGIN:|114-getter|2|
        return okCommand3;
    }
    //</editor-fold>//GEN-END:|114-getter|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: backCommand1 ">//GEN-BEGIN:|117-getter|0|117-preInit
    /**
     * Returns an initiliazed instance of backCommand1 component.
     * @return the initialized component instance
     */
    public Command getBackCommand1() {
        if (backCommand1 == null) {//GEN-END:|117-getter|0|117-preInit
            // write pre-init user code here
            backCommand1 = new Command("Atras", Command.BACK, 0);//GEN-LINE:|117-getter|1|117-postInit
            // write post-init user code here
        }//GEN-BEGIN:|117-getter|2|
        return backCommand1;
    }
    //</editor-fold>//GEN-END:|117-getter|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: stringItem ">//GEN-BEGIN:|120-getter|0|120-preInit
    /**
     * Returns an initiliazed instance of stringItem component.
     * @return the initialized component instance
     */
    public StringItem getStringItem() {
        if (stringItem == null) {//GEN-END:|120-getter|0|120-preInit
            // write pre-init user code here
            stringItem = new StringItem("", "");//GEN-LINE:|120-getter|1|120-postInit
            // write post-init user code here
        }//GEN-BEGIN:|120-getter|2|
        return stringItem;
    }
    //</editor-fold>//GEN-END:|120-getter|2|



    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: task ">//GEN-BEGIN:|124-getter|0|124-preInit
    /**
     * Returns an initiliazed instance of task component.
     * @return the initialized component instance
     */
    public SimpleCancellableTask getTask() {
        if (task == null) {//GEN-END:|124-getter|0|124-preInit
            // write pre-init user code here
            task = new SimpleCancellableTask();//GEN-BEGIN:|124-getter|1|124-execute
            task.setExecutable(new org.netbeans.microedition.util.Executable() {
                public void execute() throws Exception {//GEN-END:|124-getter|1|124-execute
                    // write task-execution user code here
                }//GEN-BEGIN:|124-getter|2|124-postInit
            });//GEN-END:|124-getter|2|124-postInit
            // write post-init user code here
        }//GEN-BEGIN:|124-getter|3|
        return task;
    }
    //</editor-fold>//GEN-END:|124-getter|3|





    /**
     * Returns a display instance.
     * @return the display instance.
     */
    public Display getDisplay () {
        return Display.getDisplay(this);
    }

    /**
     * Exits MIDlet.
     */
    public void exitMIDlet() {
        switchDisplayable (null, null);
        destroyApp(true);
        notifyDestroyed();
    }

    /**
     * Called when MIDlet is started.
     * Checks whether the MIDlet have been already started and initialize/starts or resumes the MIDlet.
     */
    public void startApp() {
        if (midletPaused) {
            resumeMIDlet ();
        } else {
            initialize ();
            startMIDlet ();
        }
        midletPaused = false;
    }

    /**
     * Called when MIDlet is paused.
     */
    public void pauseApp() {
        midletPaused = true;
    }

    /**
     * Called to signal the MIDlet to terminate.
     * @param unconditional if true, then the MIDlet has to be unconditionally terminated and all resources has to be released.
     */
    public void destroyApp(boolean unconditional) {
    }

    public void principal(){
         wait_screen.finHilo();
         switchDisplayable(null, getForm());
    }

    public void visualizaMenu(){
       wait_screen.finHilo();
       List lista_principal = getLista_menu();
       lista_principal.setTicker(new Ticker("Usuario : "+nombre_usuario));
       switchDisplayable(null,lista_principal );
    }

    public void reportaError(String msg){
       wait_screen.finHilo();
       switchDisplayable(new Alert("Error",msg,null,AlertType.ERROR),loginScreen);
    }
}
